﻿#ifndef TCPSERVERASSISTANT_H
#define TCPSERVERASSISTANT_H

#include <QMainWindow>

#include <QThread>
#include <QTcpSocket>
#include <QUdpSocket>
#include "myserver.h"
#include <QButtonGroup>

namespace Ui {
class TcpServerAssistant;
}

class TcpServerAssistant : public QMainWindow
{
    Q_OBJECT

public:
    explicit TcpServerAssistant(QWidget *parent = nullptr);
    ~TcpServerAssistant();

    Ui::TcpServerAssistant *ui;
    bool m_serverHexSend;                           //tcp服务器hex发送标志

private:

    SocketHelper* sockethelper;                     //socket创建辅助对象
    QList<MyThread*> list_thread;                   //线程列表
    QList<SocketInformation> list_information;      //socket信息列表
    MainWindow* mainwindow;

    MyServer* m_tcpServer;

private slots:

    void on_btn_serverSend_clicked();
    void on_btn_serverListering_clicked();
    void on_btn_serverClearRec_clicked();
    void on_btn_serverClearSend_clicked();

    void on_chk_ServerRecHex_clicked(bool checked);
    void on_comboBox_currentIndexChanged(int index);
    void on_btn_serverCloseSocket_clicked();

    void on_find_bt_clicked();

public slots:

    void on_add_serverMessage(QString message);

    /* 记录客户端数据 */
    void comboBox_remove();
    void comboBox_addItem(QString &atext , QVariant auserData);
    void comboBox_removeItem(int index);

    /* 发送获取客户端的系统消息指令 */
    void getSendClientSysCmd(MySocket* mysocket);
    void getShowClientDeviceSys(QByteArray *msg);
};

#endif // TCPSERVERASSISTANT_H
